#ifndef DOWNLOADMANAGER_H
#define DOWNLOADMANAGER_H

#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QUrl>
#include <QNetworkReply>
#include <QFile>
#include <QDebug>
#include <QFileInfo>
#include <QMap>
#include "databasemanager.h"
#include "centerform.h"


class DownloadManager : public QObject
{
    Q_OBJECT
public:
    explicit DownloadManager(QObject *parent = 0);
    ~DownloadManager();

    void startDownload(QString url, QString folder, int priority, int id);

private:
    int prevProgress;
    QNetworkAccessManager *manager;
    QNetworkRequest::Priority convertPriority(int priority);
    QNetworkReply *currentDownload;
    QMap<QString, QString> url2folder;
signals:
    void progressUpdate();
public slots:
    void replyFinished(QNetworkReply* reply);
    void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
};

#endif // DOWNLOADMANAGER_H
